import type { ApiResult, PageParam, PageResult } from '~/types/global'
import { request } from '~/utils/request'
import {DataAnalysis, DeviceControlCommand, DeviceOverview, Message, YearMonthWeekDayData} from '~/types/system/mseeage'
import {MonitorData} from "~/types/system/mseeage";


enum Api {
  getMessage = '/dashboard/current',
  getMessageHour = '/dashboard/hour',
  sendMessage = '/devices/ac',
  sendEnergyMode = '/dashboard/eco-mode',
  getAllDeviceOverviewApi = '/devices/getAllDevices',
}

/**
 * // 获取页面头列表
 * @return
 */
export function getMessagePageApi() {
  return request.post<ApiResult<MonitorData>>(Api.getMessage, { data: null })
}


/**
 * 获取年月周日 时时数据
 * @return
 */
export function getMessageHourApi(dataAnalysis: DataAnalysis) {
  return request.post<ApiResult<PageResult<YearMonthWeekDayData>>>(Api.getMessageHour, { data: dataAnalysis })
}

/**
 * 发送设备控制指令
 * @return
 */
export function sendMessageApi(param: DeviceControlCommand) {
  return request.post<ApiResult<boolean>>(Api.sendMessage, { data: param })
}


/**
 * 节能模式指令集
 * @param param
 * @return
 */
export function sendEnergyModeApi() {
  return request.post<ApiResult<boolean>>(Api.sendEnergyMode, { data: null })
}

/**
 * 获取所有设备概览
 */
export function getAllDeviceOverviewApi() {
  return request.post<ApiResult<DeviceOverview[]>>(Api.getAllDeviceOverviewApi, { data: null })
}
//
// /**
//  * 删除
//  * @param id
//  * @return
//  */
// export function deleteConfigApi(id: string) {
//   return request.delete<ApiResult<boolean>>(`${Api.AddConfig}/${id}`)
// }
//
// /**
//  * 批量删除
//  * @param ids
//  * @return
//  */
// export function batchDeleteConfigApi(ids: string[]) {
//   return request.delete<ApiResult<boolean>>(Api.Batch, { data: ids })
// }
//
// /**
//  * 根据code 查询字典项
//  */
// export function getConfigDictItemApi(code: string) {
//   return request.post<ApiResult<SysDictItem[]>>(Api.getDictItem, { data: { code } })
// }
